//
//  HECommentGoodsCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/10.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HECommentGoodsCell.h"

@interface HECommentGoodsCell ()

@property (nonatomic, strong) UIImageView *goodsimgView;
@property (nonatomic, strong) UILabel *titleLb;

@end

@implementation HECommentGoodsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    // 商品图片
    _goodsimgView = [UIImageView new];
    _goodsimgView.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_goodsimgView];
    _goodsimgView.userInteractionEnabled = YES;
    
    // 商品名称
    _titleLb = [UILabel new];
    _titleLb.text = @"-";
    _titleLb.font = DYFont(16);
    _titleLb.numberOfLines = 2;
    [self.contentView addSubview:_titleLb];
    
    [_goodsimgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.width.height.mas_offset(65);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-15);
    }];
    [_goodsimgView hg_setAllCornerWithCornerRadius:6.0f];

    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_goodsimgView).mas_offset(10);
        make.left.equalTo(_goodsimgView.mas_right).mas_offset(15);
        make.right.equalTo(self.contentView.mas_right).mas_offset(-15);
    }];
}

- (void)refreshContent:(GDFiterCellModel *)fiterModel formModel:(GDFormModel *)formModel indexPath:(NSIndexPath *)indexPath {
    HEOrderItemModel *model = formModel.od_details.orderItemList[indexPath.section];
    _titleLb.text = model.productName;
    
    [_goodsimgView sd_setImageWithURL:[NSURL URLWithString:model.productPic] placeholderImage:IMAGE_NAMED(@"noImage")];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
